<template>
	<view>
		<view class="staff">
			<view class="staff-em"></view>
			<view class="staff-text">活动列表</view>
		</view>

		<!-- <scroll-view scroll-y :style="'height:'+scrollH+'px;'" class="mt-2 line-h-md"> -->
			<view v-if="activity_list_data.length">
				<block v-for="(item,index) in activity_list_data" :key="index">
					<view class="box">
						<view class="ml-2 mr-2 mt-2">
							<view class="contenttext"><text>活动名称：</text>{{item.title}}</view>
							<view class="contenttext"><text>活动内容：</text>{{item.content}}</view>
							<view class="contenttext"><text>创建时间：</text>{{item.activity_create_time}}</view>
							<view class="contenttext"><text>商家名称：</text>{{item.factory_info.name}}</view>
							<view class="contenttext"><text>参与时间：</text>{{item.create_time}}</view>
						</view>

						<view class="link">
							<view @click="details(index)">活动详情 >></view>
							<view @click="mange(index)">邀约员工 >></view>
							<view @click="modify(index)">商家信息 >></view>
						</view>
					</view>
					<!-- <divider /> -->
				</block>
				
				<uni-load-more :status="status" class="mt-3 pb-2" />
				
			</view>

			<view v-else>
				<view class=" m-5 text-center font-xmd">还未参加任何活动！</view>
			</view>
		<!-- </scroll-view> -->
	</view>
</template>

<script>	
	import uniLoadMore from '../../components/common/uni-load-more.vue'
	export default {
		components: {
			uniLoadMore,
		},
		props: {
			status: null,
			activity_list_data: Array,
			scrollH: null,
		},
		methods: {
			//先获取审核状态，再打开管理页面
			mange(index) {
				/* activity_id缓存到本地
				uni.setStorage({
					key: 'activity_id',
					data: this.activity_list_data[index].id,
					success: function() {
						console.log('success');
					},
					fail: (res) => {
						console.log('缓存出错')
					}
				}); */
				// console.log(this.activity_list_data,this.activity_list_data[index].activity_id)
				this.$comm.request({
					url: 'api/factory_status',
					method: 'GET',
					data: {
						activity_id: this.activity_list_data[index].activity_id
					},
					success: res => {
						var res = res.data
						// console.log(res.code + res.msg);
						if (res.code == 201) {
							uni.showToast({
								title: '还未通过管理员的审核',
								icon: 'none',
								duration: 2000
							})
						} else {
							uni.navigateTo({
								url: "/pages/factory/management?activity_id=" + this.activity_list_data[index].activity_id
							})
						}
					},
				})
			},

			//打开详情页面
			details(index) {
				// console.log(this.activity_list_data[index].id)
				uni.reLaunch({
					url: '../index/index?activity_id=' + this.activity_list_data[index].activity_id,
				})
			},
			
			modify(index) {
				uni.navigateTo({
					url: '../../pages/factory/my?activity_id=' + this.activity_list_data[index].activity_id,
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/common/main.css';
	@import  '@/common/zcm-main.css';
	
	.staff {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 50rpx;
		margin-top: 20rpx;

		.staff-em {
			height: 35rpx;
			width: 10rpx;
			background-color: #475dfc;
			border-radius: 50rpx;
		}

		.staff-text {
			font-weight: bold;
			margin-left: 10rpx;
		}
	}
	
	.box {
		background-color: #fff; 
		margin:20rpx 30rpx 20rpx 30rpx; 
		border-radius: 10rpx;
		padding: 3rpx 0 5rpx 0;
		box-shadow: 3rpx 3rpx #9B9B9B;
	}

	.contenttext {
		margin: 5rpx 0 5rpx 0;
		overflow: hidden;
		/* break-all(允许在单词内换行。) */
		word-break: break-all;
		/* 超出部分省略号 */
		text-overflow: ellipsis;
		/** 对象作为伸缩盒子模型显示 **/
		display: -webkit-box;
		/** 设置或检索伸缩盒对象的子元素的排列方式 **/
		-webkit-box-orient: vertical;
		/** 显示的行数 **/
		-webkit-line-clamp: 1;
		
		text {
			font-weight: bold;
			line-height: 45rpx;
		}
	}

	.link {
		display: flex;
		padding: 15rpx 30rpx 0 30rpx;
		text-align: center;

		view {
			color: #475dfc;
			width: 50%;
		}
	}
</style>
